home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE20 / EX1.C next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  52 lines

  1. #include <genstub.c>
  2.  
  3. // WndProc Window message procedure
  4. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  5. {
  6.    switch (uMsg)   // Process Windows messages. 
  7.    {
  8.       case WM_COMMAND:   // Process the menu items.
  9.             switch ( LOWORD( wParam ) )
  10.                 {
  11.                    case IDM_TEST:            // Write the tick count to the INI file 
  12.                        {                     
  13.                           TCHAR szBuffer[128];
  14.                           wsprintf( szBuffer, "%ld", GetTickCount() );
  15.                           WritePrivateProfileString( "TestSection",   // Section Name.
  16.                                                      "Ticks",         // Key Name.
  17.                                                      szBuffer,        // Key Value.
  18.                                                      "YOUR.INI" );    // INI File Name
  19.                           InvalidateRect( hWnd, NULL, TRUE );
  20.                           UpdateWindow( hWnd );
  21.                        }
  22.                        break;
  23.                    case IDM_EXIT:
  24.                        DestroyWindow( hWnd );
  25.                        break;
  26.                 }
  27.             break;
  28.       case WM_PAINT:
  29.             { // Display contents of Ticks key.
  30.                PAINTSTRUCT ps;
  31.                TCHAR szBuffer[128];
  32.                BeginPaint( hWnd, &ps );
  33.                wsprintf( szBuffer, "Current Tick Key's Value: %8lu", 
  34.                          GetPrivateProfileInt( "TestSection",             // Section Name
  35.                                                 "Ticks",                  // Key Name
  36.                                                 0,                        // Default Value
  37.                                                 "YOUR.INI" ) );           // INI File Name
  38.                TextOut( ps.hdc, 0, 0, szBuffer, lstrlen( szBuffer ) );
  39.                EndPaint( hWnd, &ps );
  40.             }
  41.             break ;
  42.       case WM_DESTROY: 
  43.             PostQuitMessage( 0 );
  44.       break;
  45.       default:
  46.             return DefWindowProc( hWnd, uMsg, wParam, lParam );
  47.    }
  48.    return( 0L );
  49. }
  50.  
  51. #include <about.c>
  52.